package algorithm;

public class leetcode_0409 {
    public int longestPalindrome(String s) {
        int len=s.length();
        int [] list=new int[52];
        for(int i=0;i<len;++i){
            char a=s.charAt(i);
            if(a<='z'&&a>='a'){
                list[a-'a']+=1;
            }
            else{
                list[a-'A'+26]+=1;
            }
        }
        int maxlen=0;
        int max=0;
        for(int i=0;i<52;++i){
            if(list[i]%2==0){
                maxlen+=list[i];
            }
            else{
                maxlen+=list[i];
                maxlen-=1;
                max=1;
            }
        }
        return maxlen+max;
    }
}
